import React, { useState } from 'react'
import B from './B';
//1. 导入 createContext 函数
import { createContext } from 'react';
//2. 创建 cocntext 对象
export let context = createContext();

export default function A() {
  //声明状态
  let [data, setData] = useState(0);

  return (
    <div>
      <h2>A</h2>
      <hr />
      {/* 3. 使用 context.Provider 进行包裹 */}
      <context.Provider value={[data, setData]}>
        <B />
      </context.Provider>
    </div>
  )
}
